<style type="text/css">
	#search_options label{width:60px;}
	#form_search #submit{
		background:url('/image/global/button_search.png')  no-repeat scroll 0 0 transparent;
		margin-top:5px;
		width:60px;
		height:30px;
		cursor:pointer;
		float:right;
	}
	#form_search #submit:hover{background:url('/image/global/button_search.png') no-repeat scroll 0 -30px transparent;}
	#bottom_nav{
		height:25px;
		width:100%;
	}
	#button_last_page{
		background:url('/image/global/button_last_page.png')  no-repeat scroll 0 0 transparent;
		width:60px;
		height:25px;
		cursor:pointer;
		float:right;
	}
	#button_last_page:hover{background:url('/image/global/button_last_page.png') no-repeat scroll 0 -25px transparent;}
	#button_next_page{
		background:url('/image/global/button_next_page.png')  no-repeat scroll 0 0 transparent;
		width:60px;
		height:25px;
		cursor:pointer;
		float:right;
	}
	#button_next_page:hover{background:url('/image/global/button_next_page.png') no-repeat scroll 0 -25px transparent;}
	.result_item{cursor:pointer;}
	.result_item:hover{background-color:#F9F9F9;}
</style>
<script type="text/javascript">
	$(document).ready(function(){
		var pageId = parseInt($("#form_search #input_page").val());
		$("#form_search #input_page").val(0);
		$("#search_options #type" + ${c.searchType}).attr("checked", "checked");
		$("#search_options").buttonset();
		$("#form_search #submit").click(function(){$("#form_search").submit();});
		if ($("#button_last_page").size()){
			$("#button_last_page").click(function(){
				$("#form_search #input_page").val(pageId - 1);
				$("#form_search").submit();
			});
		}
		if ($("#button_next_page").size()){
			$("#button_next_page").click(function(){
				$("#form_search #input_page").val(pageId + 1);
				$("#form_search").submit();
			});
		}
		$(".result_item").click(function(){window.location = $(this).attr("alt");});
	});
</script>
<div id="search_bound">
	<h1>搜索</h1>
	<div class="page_column_left_padding15">
		<div class="top"></div>
		<div class="content">
			<form id="form_search" action="/search" method="get">
				<div>
					<label>关键字</label>
					% if 'q' in request.GET :
						<input name="q" value="${request.GET['q']}"></input>
					% else :
						<input name="q"></input>
					% endif
				</div>
				<div>
					<label>搜索选项</label>
					<span id="search_options">
						<input type="radio" id="type1" name="type" value="1"/><label for="type1">地点</label>
						<input type="radio" id="type2" name="type" value="2"/><label for="type2">话题</label>
						<input type="radio" id="type3" name="type" value="3"/><label for="type3">优惠</label>
					</span>
					<span id="submit"></span>
				</div>
				<input type="hidden" name="page" value="${c.page}" id="input_page"></input>
			</form>
			% if c.errMsg == 'too fast' :
				<div style="width:100%;height:20px;clear:both;"></div>
				<h2>您的搜索请求提交过于频繁，请稍候再试。</h2>
			% elif c.result != None :
				<div style="width:100%;height:20px;clear:both;"></div>
				<h2>搜索结果</h2>
				<div style="width:100%;height:5px;clear:both;"></div>
				% if c.resultCount == 0 :
					<div style="margin-left:10px;">搜索结果为空。</div>
				% else :
					% if c.searchType == '1' :
						% for r in c.result :
							<div class="result_item" style="border-top:1px solid #EEEEEE;padding:5px;" alt="/map/maploc?id=${r.id}">
								<div style="font-size:14px;font-weight:bold;">${r.name}</div>
								<div>${r.address}</div>
							</div>
						% endfor
					% elif c.searchType == '2' :
						% for r in c.result :
							<div class="result_item" style="border-top:1px solid #EEEEEE;padding:5px;" alt="/map/maploc/topic?id=${r.id}">
								<div style="font-size:14px;font-weight:bold;">${r.title}</div>
								<div>By ${r.user.name}</div>
							</div>
						% endfor
					% elif c.searchType == '3' :
						% for r in c.result :
							<div class="result_item" style="border-top:1px solid #EEEEEE;padding:5px;" alt="/map/maploc?id=${r.store.id}">
								<div style="font-size:14px;font-weight:bold;">${r.name}</div>
								<div>商户：${r.store.mapLoc.name}</div>
							</div>
						% endfor
					% endif
				% endif
				% if c.page * 20 + 20 < c.resultCount or c.page > 0 :
					<div id="bottom_nav">
						<span style="float:left;color:#666666;">第${c.page + 1}页，共${(c.resultCount - 1) / 20 + 1}页</span>
						% if c.page * 20 + 20 < c.resultCount :
							<span id="button_next_page"></span>
						% endif
						<span style="float:right;width:10px;height:10px;"></span>
						% if c.page > 0 :
							<span id="button_last_page"></span>
						% endif
					</div>
				% endif
			% endif
		</div>
		<div class="bottom"></div>
	</div>
	<div class="page_column_right_padding_left30">
		<div class="top"></div>
		<div class="content">
			<h2>TIPS</h2>
			<p>搜索时，您可以输入多个关键词，中间用空格隔开。</p>
		</div>
		<div class="bottom"></div>
	</div>
</div>
